<template>
    <div class="toast">
        <i :class="getclass"></i>
        <span>{{toastMsg}}</span>
    </div>
</template>
<script>
import { mapState } from "vuex"
export default {
    computed: {
        ...mapState({
            toastMsg: (state) => state.Toast.toastMsg,
            toasType: (state) => state.Toast.toasType
        }),
        getclass() {
            if (this.toasType == "success") {
                return "iconfont icon-toast_chenggong"
            } else if (this.toasType == "danger") {
                return "iconfont icon-toast-shibai_huaban"
            } else if (this.toasType == "warning") {
                return "iconfont icon-toast-jinggao"
            }
            return "iconfont icon-toast-shibai_huaban"
        }
    }
}
</script>
 
<style lang = "less" scoped>
.toast {
    position: fixed;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    border-radius: 10px;

    .iconfont {
        margin-right: 10px;
    }

    .icon-toast-shibai_huaban {
        color: red;
    }

    .icon-toast_chenggong {
        color: green;
    }

    .icon-toast-jinggao {
        color: orange;
    }
}
</style>